package com.iss.demo.controller;

import com.iss.demo.entity.SaleCount;
import com.iss.demo.model.MyResponseData;
import com.iss.demo.service.SaleCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("SaleCount/")
public class SaleCountController {

    @Autowired
    private SaleCountService service;
    @RequestMapping("selectAll")
    public List<SaleCount> selectAll(HttpServletRequest request){
        List<SaleCount> list = service.selectAll();
        return list;
    }

    @RequestMapping("selectById")
    public MyResponseData selectById(Integer s_id){
        SaleCount saleCount=service.selectById(s_id);
        MyResponseData responseData = new MyResponseData();
        responseData.setErrorCode(0);
        responseData.setStatus("success");
        responseData.setObject(saleCount);
        return responseData;
    }

    @RequestMapping("update")
    public MyResponseData update(SaleCount saleCount){
        Integer count = service.update(saleCount);
        MyResponseData responseData = new MyResponseData();
        responseData.setErrorCode(0);
        responseData.setStatus("更新了销量");
        return responseData;
    }
}
